package com.cong.modules.news.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cong.common.util.StringUtils;
import com.cong.modules.news.mapper.NewsArticleMapper;
import com.cong.modules.news.model.NewsArticle;
import com.cong.modules.news.service.INewsArticleService;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 新闻文章表 服务实现类
 */
@Service
public class NewsArticleServiceImpl extends ServiceImpl<NewsArticleMapper, NewsArticle>
		implements INewsArticleService {

	@Resource
	private NewsArticleMapper newsArticleMapper;

	@Override
	public List<NewsArticle> listNewsArticle(NewsArticle newsArticle) {
		LambdaQueryWrapper<NewsArticle> queryWrapper = new LambdaQueryWrapper<>();
		if (StringUtils.isNotEmpty(newsArticle.getTitle())) {
			queryWrapper.like(NewsArticle::getTitle, newsArticle.getTitle());
		}
		if (newsArticle.getSetTop() != null) {
			queryWrapper.eq(NewsArticle::getSetTop, newsArticle.getSetTop());
		}
		if (newsArticle.getStatus() != null) {
			queryWrapper.eq(NewsArticle::getStatus, newsArticle.getStatus());
		}
		return newsArticleMapper.selectList(queryWrapper);
	}

}
